<%--
  Created by IntelliJ IDEA.
  User: bb
  Date: 2021/10/15
  Time: 9:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
    if (session.getAttribute("admin") == null)
        response.sendRedirect("admin_login.jsp");
%>
<html>
<head>
    <title>后台管理首页面</title>
    <link href="jquery-easyui-1.7.0/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="jquery-easyui-1.7.0/themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="jquery-easyui-1.7.0/demo/demo.css" rel="stylesheet" type="text/css" />
    <script src="jquery-easyui-1.7.0/jquery.min.js" type="text/javascript"></script>
    <script src="jquery-easyui-1.7.0/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="jquery-easyui-1.7.0/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
</head>
<body class="easyui-layout">
    <div data-options="region:'north',border:false" style="height: 60px;background: #B3DFDA;padding: 10px">     <%--North--%>
        <div align="left">
            <div style="font-family:Microsoft YaHei;font-size: 16px;"><b>电商平台后台管理系统</b></div>
        </div>
        <div align="right">
            欢迎您，<span style="color: blueviolet; ">${sessionScope.admin.name}</span>&nbsp;|&nbsp;<a href="admin/logout">退出</a>
        </div>
    </div>
    <div data-options="region:'west',split:true,title:'功能菜单'" style="width: 180px">                          <%--West--%>
        <ul id="tree"></ul>
    </div>
    <div data-options="region:'south',border:false"                                                             <%--South--%>
         style="height: 50px;padding: 10px;text-align: center;background: lightgray">
        powered by BagPig&copy;
    </div>
    <div data-options="region:'center'" style="width: 500px;height: 500px">                                     <%--Center--%>
        <div id="tabs" data-options="fit:true" class="easyui-tabs"></div>
    </div>
    <script type="text/javascript">
        //为tree指定数据
        $('#tree').tree({
            url:'admin/getTree?adminId=${sessionScope.admin.id}',
            onClick:function (node){
                if (node.text == "商品列表"){
                    if ($('#tabs').tabs('exists','商品列表')){
                        $('#tabs').tabs('select','商品列表');
                    }else {
                        $('#tabs').tabs('add',{
                            title:node.text,
                            href:'productList.jsp',
                            closable:true
                        });
                    }
                }else if (node.text == "商品类型列表"){
                    if ($('#tabs').tabs('exists','商品类型列表')){
                        $('#tabs').tabs('select','商品类型列表');
                    }else {
                        $('#tabs').tabs('add',{
                            title:node.text,
                            href:'typeList.jsp',
                            closable:true
                        });
                    }
                }else if (node.text == "查询订单"){
                    if ($('#tabs').tabs('exists','查询订单')){
                        $('#tabs').tabs('select','查询订单');
                    }else {
                        $('#tabs').tabs('add',{
                            title:node.text,
                            href:'searchOrder.jsp',
                            closable:true
                        });
                    }
                }else if (node.text == "创建订单"){
                    if ($('#tabs').tabs('exists','创建订单')){
                        $('#tabs').tabs('select','创建订单');
                    }else {
                        $('#tabs').tabs('add',{
                            title:node.text,
                            href:'createOrder.jsp',
                            closable:true
                        });
                    }
                }else if (node.text == "用户列表"){
                    if ($('#tabs').tabs('exists','用户列表')){
                        $('#tabs').tabs('select','用户列表');
                    }else {
                        $('#tabs').tabs('add',{
                            title:node.text,
                            href:'userList.jsp',
                            closable:true
                        });
                    }
                }else if (node.text == "系统信息"){
                    if ($('#tabs').tabs('exists','系统信息')){
                        $('#tabs').tabs('select','系统信息');
                    }else {
                        $('#tabs').tabs('add',{
                            title:node.text,
                            href:'SystemInfo.html',
                            closable:true
                        });
                    }
                }else if (node.text == "退出系统"){
                    $.ajax({
                        url: 'admin/logout',
                        success:function (data){
                            window.location.href = 'admin_login.jsp';
                        }
                    })
                }
            }
        });
    </script>
</body>
</html>
